package com.example.yls.demoa;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class AddActivity extends AppCompatActivity {

    private EditText name;
    private EditText age;
    private Button add;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_add);

        add = findViewById(R.id.addStu);
        name = findViewById(R.id.addName);
        age = findViewById(R.id.addAge);

        add.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent();
                intent.putExtra("NAME",name.getText().toString());
                intent.putExtra("AGE",Integer.parseInt(age.getText().toString()));
                setResult(2001, intent);
                finish();
            }
        });

    }
}
